package com.jerry.hm.algorithm.recursion;

/**
 * 阶乘
 *
 * @author Jerry
 * @since 2024/9/30 18:56
 */
public class Factorial {

    /**
     * 计算阶乘
     *
     * @param n
     * @return
     */
    public static int fun(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        return n * fun(n - 1);
    }

    public static void main(String[] args) {
        System.out.println(fun(5));
    }
}
